var state = false;
var enable = true;
var page = 2;
var prefix = null;
function bottomInfinite(){
    if(page){
        $("#designers-list-loading img").show(function(){
            prf = '';
            if(prefix != null){
                prf = '/'+prefix;
            }
            $.get(base_url+'designers/next_page/'+page+prf, function(data) {
                $('#designers-list-loading').before(data);
                if(data.length > 10){
                    page++;
                }else{
                    page = false;
                }
                state=false;
                $("#designers-list-loading img").hide();
            });
        });
    }else{
        $("#designers-list-loading img").hide();
    }
}
$(document).ready(function(){
    $(window).scroll(function () { 
        if ($(window).scrollTop() >= $(document).height() - $(window).height()-10) {
            if(!state && enable && page){
                state=true;
                bottomInfinite();
            }
        }
    });
});
